package com.gui.mianshiya.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gui.mianshiya.common.BaseResponse;
import com.gui.mianshiya.common.ResultUtils;
import com.gui.mianshiya.model.dto.collection.CollectionAddRequest;
import com.gui.mianshiya.model.dto.question.QuestionSignRequest;
import com.gui.mianshiya.model.entity.User;
import com.gui.mianshiya.model.vo.QuestionVO;
import com.gui.mianshiya.model.vo.SignQuestionVo;
import com.gui.mianshiya.service.ExerciseRecordsService;
import com.gui.mianshiya.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @Title: ExerciseRecordsController
 * @Author quit
 * @Package com.gui.mianshiya.controller
 * @Date 2025/4/23 15:26
 * @description:
 */
@RestController
@RequestMapping("/sign")
@Slf4j
public class ExerciseRecordsController
{
    @Resource
    private ExerciseRecordsService exerciseRecordsService;

    @Resource
    private UserService userService;
    /**
     * 获取刷题列表
     *
     * @param request
     * @return
     */
    @PostMapping("/question/list")
    public BaseResponse<Page<SignQuestionVo>> addCollections(@RequestBody QuestionSignRequest questionSignRequest, HttpServletRequest request) {
        User loginUser = userService.getLoginUser(request);
        questionSignRequest.setUserId(loginUser.getId());
        Page<SignQuestionVo> page =  exerciseRecordsService.getQuestionList(questionSignRequest);
//        AbstractApplicationContext
        return ResultUtils.success(page);
    }

}
